#include "test.h"

namespace Test
{
    void testString()
    {
        // LITERAL STRING
        {
            ScannerTest test("(abc)(a\\\rb\\\nc\\\r\nd)(\\r\\)\\f\\(\\b\\t\\n)(\\53a\\0535)");

            test.checkNext( stString, "abc" );
            test.checkNext( stString, "abcd" );
            test.checkNext( stString, "\r)\f(\b\t\n" );
            test.checkNext( stString, "+a+5" );
        }
        {
        /*
            If a string is too long to be conveniently placed on a single line, it may be split
            across multiple lines by using the backslash character at the end of a line to
            indicate that the string continues on the following line. The backslash and the
            end-of-line marker following it are not considered part of the string.
        */
            ScannerTest test("(These \\\r\ntwo strings \\\rare the same.)");

            test.checkNext( stString, "These two strings are the same." );
        }
        {
            ScannerTest test("(This string contains \\245two octal characters\\307.)");

            test.checkNext( stString, "This string contains \xA5two octal characters\xC7." );
        }
        {
            ScannerTest test("(Strings may contain balanced parentheses () and special characters ( * ! & } ^ % and so on).)");

            test.checkNext( stString, "Strings may contain balanced parentheses () and special characters ( * ! & } ^ % and so on)." );
        }

        // HEXADECIMAL STRING
        {
            ScannerTest test("< 4E6 F7620\t73686D6F\r7A206B6 \n 120706F702E ><  \t>< \t< >\r>< 901FA >");

            test.checkNext( stString, "Nov shmoz ka pop." );    // White-space characters (such as space, tab, carriage return, line feed, and form feed) are ignored.
            test.checkNext( stString, "" );
            test.checkNext( stDictBeg, "" );
            test.checkNext( stWhiteSpace, " " );
            test.checkNext( stDictEnd, "" );
            test.checkNext( stString, "\x90\x1F\xA0" );         // < 901FA > is a 3-byte string containing the characters whose hexadecimal codes are 90, 1F, and A0.
        }
    }
}